잠시만 기다려 주세요

     '대한민국이 더이상 발전하지 못하는 것은 부패한 언론들의 쓰레기짓 때문이다.'
전체검색 :  
이번주 로또 및 연금번호 발생!!   |  HOME   |  여기는?   |  바다물때표   |  알림 (16)  |  여러가지 팁 (1054)  |  추천 및 재미 (150)  |  자료실 (22)  |  
시사, 이슈, 칼럼, 평론, 비평 (582)  |  끄적거림 (127)  |  문예 창작 (702)  |  바람 따라 (69)  |  시나리오 (760)  |  드라마 대본 (248)  |  
살인!


    golang

golang - golang quote escape, unquote
이 름 : 바다아이   |   조회수 : 8363         짧은 주소 : https://www.bada-ie.com/su/?581591808923
Quote

package main

import (
	"fmt"
	"strconv"
)

func main() {
	s := strconv.Quote(`"Fran & Freddie's Diner	☺"`)
	fmt.Println(s)

}


결과

"\"Fran & Freddie's Diner\t\""


Unquote 

package main

import (
	"fmt"
	"strconv"
)

func main() {
	test := func(s string) {
		t, err := strconv.Unquote(s)
		if err != nil {
			fmt.Printf("Unquote(%#v): %v\n", s, err)
		} else {
			fmt.Printf("Unquote(%#v) = %v\n", s, t)
		}
	}

	s := `\"Fran & Freddie's Diner\t\u263a\"\"`
	// If the string doesn't have quotes, it can't be unquoted.
	test(s) // invalid syntax
	test("`" + s + "`")
	test(`"` + s + `"`)
	test(`'\u263a'`)

}


결과

Unquote("\\\"Fran & Freddie's Diner\\t\\u263a\\\"\\\""): invalid syntax
Unquote("`\\\"Fran & Freddie's Diner\\t\\u263a\\\"\\\"`") = \"Fran & Freddie's Diner\t\u263a\"\"
Unquote("\"\\\"Fran & Freddie's Diner\\t\\u263a\\\"\\\"\"") = "Fran & Freddie's Diner	☺""
Unquote("'\\u263a'") = ☺


아마 대부분 이렇게 사용할 겁니다. 굳이 수작업으로 역슬래시를 입히진 않으리라 생각됩니다.
입히고 나중에 변수에 담겨 있는 것을 다시 벗고 그럴 겁니다.

package main

import (
	"fmt"
	"strconv"
)

func main() {
	s := strconv.Quote(`"Fran & Freddie's Diner	☺"`)
	fmt.Println(s)
	t, _ := strconv.Unquote(s)
	fmt.Println(t)
}


결과

"\"Fran & Freddie's Diner\t☺\""
"Fran & Freddie's Diner	☺"
| |





      1 page / 6 page
번 호 카테고리 제 목 이름 조회수
179 golang golang , ... 바다아이 1306
178 golang golang , map . 바다아이 1042
177 golang Golang (, , data ) , ... 바다아이 1045
176 golang golang sort ... 바다아이 1215
175 golang golang html.EscapeString html.UnescapeString input value ... 바다아이 1385
174 golang golang go.mod go.sum . GOPATH SRC not module, 1.16 . 바다아이 4527
173 golang go 1.16 ... is not in GOROOT.. GOPATH .... . 바다아이 5362
172 golang , String Formatting 바다아이 6940
171 golang rand.Intn , random, , . 바다아이 6525
170 golang golang ... 바다아이 9276
169 golang golang gopath, goroot .. golang 바다아이 7111
168 golang golang ... Force download file example 바다아이 8872
167 golang golang , , cpu, memory, disk 바다아이 10159
166 golang golang , ... GOOS, GOARCH 바다아이 8046
165 golang golang checkbox ... 바다아이 7757
164 golang golang , , http .... 바다아이 7576
163 golang golang nil , nil , nil ... 바다아이 7842
162 golang 2 golang, go , .... golang .... 바다아이 10636
161 golang golang postgresql, mysql, mariadb ... ` Grave () .. .. 바다아이 8098
160 golang golang postgresql mysql, mariadb scan , null .. 바다아이 8198
159 golang golang , iconv 바다아이 10992
현재글 golang golang quote escape, unquote 바다아이 8364
157 golang golang , http errorLog , , ... 바다아이 8482
156 golang golang interface , 바다아이 7985
155 golang golang struct .... 바다아이 8657
154 golang golang map map , 바다아이 8223
153 golang golang map .... .... 바다아이 7743
152 golang golang slice copy 바다아이 7834
151 golang golang goto 바다아이 8671
150 golang golang slice sort , int, string, float64 바다아이 8102
| |









Copyright ⓒ 2001.12. bada-ie.com. All rights reserved.
이 사이트는 리눅스에서 firefox 기준으로 작성되었습니다. 기타 브라우저에서는 다르게 보일 수 있습니다.
[ Ubuntu + GoLang + PostgreSQL + Mariadb ]
서버위치 : 오라클 클라우드 춘천  실행시간 : 0.05734
to webmaster... gogo sea. gogo sea.